package cz.boxdesign.library.web.decorator;

import java.util.Calendar;

import org.displaytag.decorator.TableDecorator;

import cz.boxdesign.library.entity.User;

public class UserTableDecorator extends TableDecorator {

  public String getEditUrl() {
    User user = (User) getCurrentRowObject();
    return "<a href=\"/isLibrary/users/edit.do?userId=" + user.getId() + "\"><img src=\"/isLibrary/images/icons/edit_16.png\"/></a>";
  }

  public String getShowUrl() {
    User user = (User) getCurrentRowObject();
    return "<a href=\"/isLibrary/users/show.do?userId=" + user.getId() + "\"><img src=\"/isLibrary/images/icons/goto_16.png\"/></a>";
  }

  public String getDeleteUrl() {
    User user = (User) getCurrentRowObject();
    return "<a href=\"javascript:openDialog('users/delete.do?userId=" + user.getId()
        + "')\"><img src=\"/isLibrary/images/icons/delete_16.gif\"/></a>";
  }

  public String getProlongUrl() {
    User user = (User) getCurrentRowObject();
    if (!user.isAdmin()) {
		Calendar cal = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		cal2.setTime(user.getObdobiDo());
		if (cal.compareTo(cal2) > 0) {
			return "<a href=\"/isLibrary/users/prolong.do?userId=" + user.getId() + "\">Prolong Registration</a>";
		} else {
			return "Prolong Registration";
		}
	}
    return "Admin";
  }
}
